﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using TheCup;
using TheCup.Infrastructure;
using TheCup.Models;

/// <summary>
/// Summary description for TheCupRoleProvider
/// </summary>
public class TheCupRoleProvider : RoleProvider
{
	public TheCupRoleProvider()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public override void AddUsersToRoles(string[] usernames, string[] roleNames)
    {
        throw new NotImplementedException();
    }

    public override string ApplicationName
    {
        get
        {
           return "TheCup";
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public override void CreateRole(string roleName)
    {
        throw new NotImplementedException();
    }

    public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
    {
        throw new NotImplementedException();
    }

    public override string[] FindUsersInRole(string roleName, string usernameToMatch)
    {
        throw new NotImplementedException();
    }

    public override string[] GetAllRoles()
    {
        throw new NotImplementedException();
    }

    public override string[] GetRolesForUser(string username)
    {
        List<string> roles = new List<string>();

        // by default and for legacy support, everyone gets the Players role
        roles.Add("Players");
        TheCupContext context = new TheCupContext();
        Player player = (from p in context.Players
                         where p.Initials == username
                         select p).First();
        if ((bool) player.IsAdministrator)
            roles.Add("Administrators");
        return roles.ToArray();
    }

    public override string[] GetUsersInRole(string roleName)
    {
        throw new NotImplementedException();
    }

    public override bool IsUserInRole(string username, string roleName)
    {
        throw new NotImplementedException();
    }

    public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
    {
        throw new NotImplementedException();
    }

    public override bool RoleExists(string roleName)
    {
        throw new NotImplementedException();
    }
}